import request from '@/utils/request.js';

// 登录请求接口
export const login = data => {
  return request({
    method: 'POST',
    url: 'login',
    data
  });
};

// 左侧菜单接口
export const menus = () => {
  return request({
    method: 'GET',
    url: 'menus'
  });
};

// 用户列表接口
export const users = (params) => {
  return request({
    method: 'get',
    url: 'users',
    params
  });
};

// 修改用户列表状态
export const upUsers = (uid, type) => {
  return request({
    method: 'PUT',
    url: `users/${uid}/state/${type}`
  });
};

// 添加用户
export const addUsers = (data) => {
  return request({
    method: 'POST',
    url: 'users',
    data
  });
};

// 根据id查询用户信息
export const checkUser = (id) => {
  return request({
    method: 'GET',
    url: `users/${id}`
  });
};

// 编辑用户提交
export const editCheckUser = (data) => {
  return request({
    method: 'PUT',
    url: `users/${data.id}`,
    data
  });
};

// 删除单个用户
export const delectUserRadio = (id) => {
  return request({
    method: 'DELETE',
    url: `users/${id}`
  });
};

// 角色列表
export const rolesList = () => {
  return request({
    method: 'GET',
    url: 'roles'
  });
};

// 分配用户角色
export const showUsersRole = (id, data) => {
  return request({
    method: 'PUT',
    url: `users/${id}/role`,
    data
  });
};
